/**
 * created by dt at 2025/5/7
 */

import { Entity } from "../../../core/Entity";

export interface IBuffEffect {
    onAdd(entity: Entity): void;
    onRemove(entity: Entity): void;
    onUpdate(entity: Entity, deltaTime: number): void;
}

export class BuffEffectBase implements IBuffEffect {
    onUpdate(entity: Entity, deltaTime: number): void {
    }
    onAdd(entity: Entity): void {
        throw new Error("Method not implemented.");
    }
    onRemove(entity: Entity): void {
        throw new Error("Method not implemented.");
    }
}

/**
 * 周期性生效的buff
 */
export class BuffEffectPeriodic extends BuffEffectBase {
    private _interval: number;
    private _lastTime: number;
    constructor(interval: number) {
        super();
        this._interval = interval;
        this._lastTime = 0;
    }

    onUpdate(entity: Entity, deltaTime: number): void {
        this._lastTime += deltaTime;
        if (this._lastTime >= this._interval) {
            this._lastTime = 0;
            this.onTrigger(entity);
        }
    }

    onTrigger(entity: Entity): void {
    }
}